/* Janus Chat - Version 1.0
 * Authors: Matthew Perry
 *          Michael Freid
 *          Marc Latou
 *          Richard Lee
 *
 * The Janus Chat Client is a highly secured
 * peer-to-peer chat client designed to facilitate
 * the transfer of sensitive data or as a communication
 * medium for the extra paranoid
 *
 * This file contains the header for the ChatTab
 * QT class which is where the user will be spending most */

#ifndef CHATTAB_H
#define CHATTAB_H

#include <QWidget>
#include <QTcpSocket>
#include "../lib/chat.h"
#include "../lib/message.h"
#include "../lib/user.h"

namespace Ui {
    class ChatTab;
}

class ChatTab : public QWidget
{
    Q_OBJECT

    public:
        explicit ChatTab( User* user, QTcpSocket* sock, bool host = false, QWidget* parent = 0);
        ~ChatTab();

        void disconnectChat();          /* Disconnects user from the associated chat */

    protected:
        /* Event filters are used by the QT framework to catch
         * certain events passed to an object and do with them
         * what is needed. This is implemented to catch the
         * enter button press so that a message can be sent */
        bool eventFilter( QObject* obj, QEvent* event );

    private:
        Ui::ChatTab *ui;        /* Generated by QT to store all the UI elements */

        Chat myChat;            /* A Chat class which this tab is associated */
        User* myUser;           /* Pointer to information about the user */

    private slots:
        void on_buttonSmiley_clicked(); /* This slot is activated when the smiley button is clicked */
        void on_buttonSend_clicked();   /* This slot is activated when the send button is clicked */
        void printMsg( const Message& msg, const QString& color ); /* prints the given message with the given color */
        void printDis( const QString& name );   /* Prints that NAME has disconnected from the chat */
};

#endif // CHATTAB_H
